package cn.edu.zafu.bigdata.yt;

// 定义 Book 类
class Book {
    // 字段
    private String title;
    private String author;
    private double price;

    // 带参构造器
    public Book(String title, String author, double price) {
        this.title = title;
        this.author = author;
        this.price = price;
    }

    // 重写 toString() 方法
    @Override
    public String toString() {
        return "Book[title=" + title + ", author=" + author + ", price=" + price + "]";
    }
}

// 测试类
public class BookTest {
    public static void main(String[] args) {
        // 创建几个 Book 对象
        Book book1 = new Book("Java Programming", "John Doe", 29.99);
        Book book2 = new Book("Effective Java", "Joshua Bloch", 39.99);
        Book book3 = new Book("Clean Code", "Robert C. Martin", 45.00);

        // 打印 Book 对象的信息
        System.out.println(book1); // 输出: Book[title=Java Programming, author=John Doe, price=29.99]
        System.out.println(book2); // 输出: Book[title=Effective Java, author=Joshua Bloch, price=39.99]
        System.out.println(book3); // 输出: Book[title=Clean Code, author=Robert C. Martin, price=45.0]
    }
}

